# 123报数游戏

def calculate_last(que: list, number: int):
    num = 0
    while len(que) > 1:
        qu = que[:]
        for i in qu:
            num = num + 1
            # print("当前第{}号,报数{}".format(i, num))
            if num == number:
                que.remove(i)
                # print("当前", i, "被移出", "移除后队列   ->", que)
                num = 0
    else:
        print("最终胜者：", que[0])


while True:
    while True:
        ins = input("请输入玩123...N报数游戏人数：")
        if not ins.isdigit():
            print("请输入数字，别输错了，再来~")
        else:
            que_num = int(ins)
            que = [i + 1 for i in range(que_num)]
            break
    while True:
        ins = input("请输入玩123...N报数游戏退出数字：")
        if ins == '1':
            print("已经是最后一个人了")
        elif not ins.isdigit():
            print("请输入数字，别输错了，再来~")
        else:
            number = int(ins)
            break
    calculate_last(que, number)
